<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>新增机场addAirportMaintaince</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />

	<style>
		body{
			background:#eeeeee;
		}
		.newPlan{
			background:#ff7777;
		}
		.btnBox{
			width:100%;
			text-align:center;
			margin-top:35px;
		}
		.addAir{
			width:400px;
			margin-top:55px;
		}
		p{
		    margin:0 auto;
			color:#959ca2;
			width:330px;
			height:30px;
			margin-top:15px;
			line-height:30px;
			text-align:right;
		}
		
		input,select{
			width:200px;
			height:100%;
			margin-left:10px;
			padding-left:10px;
			font-family:"微软雅黑";
		}
		select{
			width:214px;
		}
		.cancel{
		margin-left:15px;
		background-color:#afb1b0;
		}
		
		/* 机场三字码联想 */
		.airportCode{
			position:relative;
		}
		
		.threeWordBox{
			overflow-x:hidden;
			width:218px;
			height:160px;
			background:white;
			border:1px solid #f1f1f1;
			border-radius:5px;
			position:absolute;
			right:0px;
			top:35px;
		}
		
	</style>
	<body>
		<div class="addAir">
			<p class='airportCode'>机场三字码:<input class='val1' type="text"  /><strong style="color:red;">*</strong></p>
			<p class='chinese'>机场中文名称:<input readonly class='val2' type="text"  /><strong style="color:red;">*</strong></p>
			<p class='hotArtport'>是否为热点机场:<select class='val4'><option value='0'>非热点</option><option value="1">热点</option></select><strong style="color:#f1f1f1;">*</strong></p>
		</div>
		
		<div class='btnBox'>
			<button class='Dolo_btn sure'>确认</button>
			<button class='Dolo_btn cancel'>取消</button>
		</div>
		
		
	</body>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<!-- 引入my97日期时间控件 -->
		<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		<script>											
			$(".sure").click(function(){	
				var submitMess = {};
				submitMess.airportCode = $(".val1").val();
				submitMess.airportCnNm = $(".val2").val();
				submitMess.airportHot = $(".val4").val();
				layer.msg('添加中...', {icon: 16,shade: 0.01});
				$.ajax({
					type:"post",
					url:"../Airapt/add?temp="+Math.random(),
					contentType:'application/json;charset=utf-8',
					async:true,
					data:JSON.stringify(submitMess),
					success:function(data){
						data=JSON.parse(data)
						if(data.status=="1001"){
							layer.msg('添加机场成功', {icon: 1,time:1000},function(){
								var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
								parent.layer.close(index);//关闭弹窗
							})	
						}if(data.status=="1002"){
							layer.msg("添加机场失败,"+data.message,{icon: 2,time:2000},function(){								
							})
						}
					}
						
				});	
			}) 
		
		//_____________________________________________________________________________新增机场取消
			$(".cancel").click(function(){
				closeWin()
			})	
		//_____________________________________________________________________________机场联想
			$(".val1").keyup(function(){
				getCode()
			})
			$(".airportCode").delegate(".CnNm","click",function(){
				$(".val1").val($(this).find("i[class=i2]").text())
				$(".val2").val($(this).find("i[class=i1]").text())
				$(".threeWordBox").remove();
			})	
			$(".airportCode").delegate(".threeWordBox","mouseleave",function(){				
				$(".threeWordBox").remove();
			})	
			
			function getCode(){
				var threeWord = $(".val1").val();	
				$(".threeWordBox").remove();
				$.ajax({
					type:"get",
					url:"../Airapt/query?airapt="+threeWord+"&useable=ns&temp="+Math.random(),
					dataType:"json",
					success:function(data){	
						var str1="";
						str1+="<i class='threeWordBox'></i>";
						$(".airportCode").append(str1)
						var str2="";						
						for(var i=0;i<data.data.length;i++){
							str2+="<p class='CnNm' style='cursor:pointer;overflow:hidden;width:100%;height:20px;line-height:20px;padding-left:5px;text-align:center;'><i class='i1'>"+data.data[i].airportCnNm+"</i><i class='i2'>"+data.data[i].airportCode+"</i></p>"
						}
						$(".threeWordBox").append(str2);
						
					}
				})
			}
		</script>			
</html>
